package noncomunicating.classes.SSI;

import noncomunicating.classes.Request;
import comunicating.classes.ServerLoop;

import util.Regex;

public abstract class Directive {
	public String cmt;
	private SSIParser parser;
	
	public Directive(String cmt, SSIParser parser) {
		super();
		this.cmt = cmt;
		this.parser = parser;
	}

	public void subTag(String tag, String sub){
		parser.fileString = parser.fileString.replace(tag, sub);
	}
	
	public String getCallDirectory(){
		String fs = parser.request.getFileString();
		String fileDir = Regex.firstMatch("/[a-zA-Z0-9/]+/", fs); //finds the /.../.../.../ of a URL
		return fileDir.replace(ServerLoop.directory, ""); //XXX there are probably better ways to do this
	}
	
	public Request getRequest(){
		return parser.request;
	}
	
}
